﻿package Cain.mk
{
	import Cain.arr_acc;
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import caurina.transitions.Tweener;
	public class uuit 
	{
		private var mc:DisplayObject;
		private var _mk_width:Number = 50;
		private var _x_n:int;
		private var _y_n:int;
		private var _mk_arr:Array;
		public function uuit(_mc:DisplayObject) 
		{
			mc = _mc;
			init();
		}
		
		private function init():void
		{
			num_init();
			mk_init();
			
			_mk_arr = arr_acc.random(_mk_arr);
			for (var i:int = 0; i < _mk_arr.length; i++) 
			{
				Tweener.addTween(_mk_arr[i], { scaleX:0, scaleY:0, time: .5, delay:i * .01,transition:"easeOutQuad" } );
			}
			
		}
		private function num_init():void 
		{
			_x_n = Math.floor(mc.width / _mk_width);
			if (mc.width % _mk_width != 0)
			{
				_x_n++;
			}
			_y_n = Math.floor(mc.height / _mk_width);
			if (mc.width % _mk_width != 0)
			{
				_y_n++;
			}
		}
		private function mk_init():void 
		{
			_mk_arr = new Array();
			var _mk_mv:Sprite = new Sprite();
			_mk_mv.cacheAsBitmap = true;
			Sprite(mc).addChild(_mk_mv);
			mc.mask = _mk_mv;
			for (var i:int = 0; i < _y_n; i++) 
			{
				for (var j:int = 0; j < _x_n; j++) 
				{
					var _mk:Mk = new Mk();
					_mk.x = j * _mk_width + _mk_width / 2;
					_mk.y = i * _mk_width + _mk_width / 2;
					_mk_mv.addChild(_mk);
					_mk_arr.push(_mk);
				}
			}
		}
	}
	
}